import { http, type ResultList, type ResultBoolean } from "@/utils/http";

// 获取附近兴趣点
export const getNearbyPoi = (params: {
  latitude: number;
  longitude: number;
  radius: number;
  pageNum: number;
  pageSize: number;
}) => {
  return http.request<ResultList>("get", "/api/poi/nearby", { params });
};

// 获取兴趣点详情
export const getPoiDetail = (id: number) => {
  return http.request<ResultList>("get", `/api/poi/${id}`);
};

// 收藏兴趣点
export const favoritePoi = (id: number) => {
  return http.request<ResultBoolean>("post", `/api/poi/favorite/${id}`);
};

// 取消收藏兴趣点
export const cancelFavoritePoi = (id: number) => {
  return http.request<ResultBoolean>("delete", `/api/poi/favorite/${id}`);
};

// 分页条件查询兴趣点
export const getPoiPage = (data?: object) => {
  return http.request<ResultList>("post", "/api/poi/page", { data });
};

// 新增兴趣点
export const createPoi = (data: PoiDTO) => {
  return http.request<ResultBoolean>("post", "/api/poi/add", { data });
};

// 编辑兴趣点
export const updatePoi = (data: PoiDTO) => {
  return http.request<ResultBoolean>("post", "/api/poi/edit", { data });
};

// 删除兴趣点
export const deletePoi = (id: number) => {
  return http.request<ResultBoolean>("post", `/api/poi/delete/${id}`);
};

/**
 * 兴趣点DTO接口定义
 */
export interface PoiDTO {
  id?: number;
  name: string;
  address: string;
  introduction: string;
  poiType: string;
  recommendationScore: number;
  longitude: number;
  latitude: number;
  coverImageUrl: string;
}
